package com.jincheng.service.impl;

import com.jincheng.mapper.AuctionuserMapper;
import com.jincheng.pojo.Auctionuser;
import com.jincheng.service.AuctionuserService;
import com.jincheng.utils.MybatisUtil;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * @author Jane
 * @date 2024-12-13 10:01
 */
//@Component
//@Component("auctionuserService")
@Service("auctionuserService")
public class AuctionuserServiceImpl implements AuctionuserService {

    @Override
    public Auctionuser login(String username, String password) throws Exception {

        SqlSession session = MybatisUtil.createSqlSession(false);

        Auctionuser user = session.getMapper(AuctionuserMapper.class).findUserByName(username);
        //登录
        if (null!=user){
            if (password.equals(user.getUserpassword())){
                return user;
            }else{
                throw new RuntimeException("密码错误");
            }
        }
        MybatisUtil.closeSqlSession(session);

        return  null;

    }
}
